/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package marsaMaroc.dao;

import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;

/**
 *
 * @author salah
 */
public class GraphiquesDAO {

    EntityManagerFactory emf = Persistence.createEntityManagerFactory("Marsa-MarocPU");
    EntityManager em;

    public int selectReclamationBetween(String date1, String date2) {
        EntityManager em = emf.createEntityManager();
        Query qr = em.createQuery("SELECT r FROM Reclamation r WHERE r.dateCreation BETWEEN '"+date1+"' AND '"+date2+"'");
        int nbr = qr.getResultList().size();
        return nbr;
    }
    public int selectTypeReclamations(String type) {
        EntityManager em = emf.createEntityManager();
        Query qr = em.createQuery("SELECT r FROM Reclamation r WHERE r.type= '"+type+"'");
        int nbr = qr.getResultList().size();
        return nbr;
    }

    
}
